package com.cxy.datawarehouse.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class PasswordUtils {

    private static final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();

    /**
     * @param pwd 原始密码
     * @return 加密后的密码
     */
    public static String encrypt(String pwd) {
        return passwordEncoder.encode(pwd);
    }

    /**
     * @param rawPassword     原始密码
     * @param encodedPassword 加密后的密码
     * @return true/false
     */
    public static boolean matches(String rawPassword, String encodedPassword) {
        return passwordEncoder.matches(rawPassword, encodedPassword);
    }

}
